package com.eastfair.matching.controller;

import com.eastfair.core.base.R;
import com.eastfair.matching.service.ComplementServiceProviderService;
import com.eastfair.venueservice.dto.ServiceProviderDTO;
import com.eastfair.venueservice.vo.ServiceProviderVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * 配套服务商信息
 * </p>
 *
 * @author lyw
 * @date 2022-07-15
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/complementServiceProvider")
@Api(value = "complementServiceProvider", tags = "配套服务商信息")
public class ComplementServiceProviderController {

    @Autowired
    private ComplementServiceProviderService complementServiceProviderService;

    /**
     * 查询配套服务商信息
     * @param userId
     * @return
     */
    @GetMapping("/getComplementServiceProviderByUserId/{userId}")
    public R<ServiceProviderVO> getComplementServiceProviderByUserId(@PathVariable Long userId) {
        ServiceProviderVO serviceProviderVO = complementServiceProviderService.getComplementServiceProviderByUserId(userId);
        return R.success(serviceProviderVO);
    }

    /**
     * 新增配套服务商信息
     * @return
     */
    @PostMapping("/saveComplementServiceProvider")
    public R<Boolean> saveComplementServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO){
      return R.success(complementServiceProviderService.saveComplementServiceProvider(serviceProviderDTO));

    }

    /**
     * 更新配套服务商信息
     * @return
     */
    @PostMapping("/updateComplementServiceProvider")
    public R<Boolean> updateComplementServiceProvider(@RequestBody ServiceProviderDTO serviceProviderDTO){
        return R.success(complementServiceProviderService.updateComplementServiceProvider(serviceProviderDTO));
    }
}
